package net.killerscape.packethandler;

import net.killerscape.model.Player;
import net.killerscape.net.Packet;
import net.killerscape.util.Logger;
import org.apache.mina.common.IoSession;

public class MiscPackets implements PacketHandler {
	public void handlePacket(Packet p, IoSession session) {
		Player player = (Player)session.getAttachment();
		switch(p.getId()) {
			case 187: //Losing/Gaining focus on game window..
				int Focus = p.getData()[0];
				if(Focus == 1)
					player.resetTimeoutCounter();
				/**Focus = 1 means in focus
				 * Focus = 0 means out of focus.
				 */
				break;
			case 140: //Rotating camera
				player.resetTimeoutCounter();
				break;
			case 202: //Timeout - 6 in a row = disconnect.
				player.increaseTimeoutCounter();
				if(player.getTimeoutCounter() == 3) {
					player.getActionSender().sendLogout();
					session.close();
				}
				break;
			case 110: //Click start playing on welcome screen
				Logger.err(""+player.getInventory().addItem(4151, 1));
				break;
			case 6: //User login complete
				break;
		}
	}
}
